/**
 * Created by kangdaye on 16/6/5.
 */
app.controller('distrVipListCtr',["$scope","$rootScope","ngDialog","distrVipCache", function($scope,$rootScope,ngDialog,distrVipCache) {
    $scope.tab = distrVipCache.listTab;
    $scope.getData = {
        status : undefined
    };
    $scope.gridOptions = {
        url          : servicePath + 'member/distribution_list',
        columnDefs   : distrVipCache.listTableHeader,
        params       : $scope.getData,
        selectAll    : true
    };


    $scope.tabClick = function(id){
        $scope.getData.status = id;
        $scope.gridOptions.refresh();
    };

    $scope.searchClick = function(){
        $scope.gridOptions.search();
    };

    $scope.detail = function(id,auditlog){
        ngDialog.open({
            template: '/admin/view/vip/distrVip/distrVipDetailDialog.html',
            width: 650,
            controller: 'distrVipDetailDialogCtr',
            resolve: {
                getData: function() {
                    return {
                        id : id
                    };
                },
                viewData: function() {
                    return {
                        auditlog : auditlog
                    };
                }
            }
        });
    };

    $scope.audit = function(id){
        ngDialog.open({
            template: '/admin/view/vip/distrVip/distrVipAuditDialog.html',
            width: 650,
            controller: 'distrVipAuditDialogCtr',
            resolve: {
                getData: function() {
                    return {
                        id : id
                    };
                }
            }
        });
    };

    $scope.deduct = function(id){
        ngDialog.open({
            template: '/admin/view/vip/distrVip/distrVipDeductDialog.html',
            width: 400,
            controller: 'distrVipDeductDialogCtr',
            resolve: {
                getData: function() {
                    return {
                        id : id
                    };
                }
            }
        });
    };
}]);
